package com.j283_5.wisdom_park.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.j283_5.wisdom_park.pojo.Device;
import com.j283_5.wisdom_park.pojo.DeviceInformation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author laoda
 * @since 2022-04-28
 */
@Mapper
public interface DeviceInformationMapper extends BaseMapper<DeviceInformation> {

    /**
     * 根据条件查询数据库中设备信息的所有条数
     * @return
     */
    Integer queryDeviceSum(@Param("deviceInformation") DeviceInformation deviceInformation,
                           @Param("oneAdminId")
                                   Integer adminId);

    /**
     * 根据条件查询所有的数据
     * @param deviceInformation
     * @param start
     * @param limit
     * @return
     */
    List<DeviceInformation> queryDeviceInformation(@Param("deviceInformation") DeviceInformation deviceInformation,
                                                   @Param("start")
                                                           Integer start,
                                                   @Param("limit")
                                                           Integer limit,
                                                   @Param("oneAdminId")
                                                           Integer adminId
    );

    /**
     * 根据设备id信息查询设备详细信息
     * @param dinfId
     * @return
     */
    Device queryOneDevice(@Param("dinfId") Integer dinfId);

    /**
     * 根据list批量删除
     * @param deviceIdList
     * @return
     */
    Integer deleteDevice(@Param("deviceIdList") ArrayList deviceIdList);


    /**
     * 添加device_detailed表数据
     * @param device
     * @return
     */
    Integer addDeviceDetailed(@Param("device") Device device);

    /**
     * 添加device_information表数据
     * @param device
     * @return
     */
    Integer addDeviceInformation(@Param("device") Device device, @Param("ddetId") Integer ddetId);

    /**
     * 获取上一次插入数据的主键id
     * @return
     */
    Integer getDeviceDetailedId();

}
